Land QString changes that don't require (blatant) conditional compilation
authorrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 23 Sep 2013 02:45:37 +0000 (02:45 +0000)
committerrobertlipe <robertlipe@f51c46e8-681c-474f-0cfe-069cfd0219fb>
Mon, 23 Sep 2013 02:45:37 +0000 (02:45 +0000)
that are really mechanical.

git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4625 f51c46e8-681c-474f-0cfe-069cfd0219fb

gpsbabel/bushnell.cc
gpsbabel/csv_util.h
gpsbabel/enigma.cc
gpsbabel/gtm.cc
gpsbabel/lowranceusr4.cc
gpsbabel/magellan.h
gpsbabel/naviguide.cc
gpsbabel/pcx.cc

index a8dada3bb2434fa1255ac242f3c675a065e29237..af2b2fe37c018d33758b797b5d1a888a6eb399d9 100644 (file)
@@ -242,7 +242,7 @@ bushnell_write_one(const waypoint* wpt)
   gbfputc(0x01, file_out);  // Proximity alarm.  1 == "off", 3 == armed.
 
   ident = mkshort(mkshort_handle, wpt->shortname);
-  strncpy(tbuf, wpt->shortname, sizeof(tbuf));
+  strncpy(tbuf, CSTRc(wpt->shortname), sizeof(tbuf));
   tbuf[sizeof(tbuf)-1] = 0;
   gbfwrite(tbuf, sizeof(tbuf), 1, file_out);
 
index ed4f2e3b564009fa3fd59225c99b98b071a034c3..356848135f6c96b424da498abfd18f1b8303871e 100644 (file)
@@ -40,6 +40,7 @@ csv_stringclean(const char* string, const char* chararray);
 CSV_STRINGCLEAN(const char* string, const char* chararray,DEBUG_PARAMS);
 #define csv_stringclean(s,c) CSV_STRINGCLEAN(s,c,__FILE__,__LINE__)
 #endif
+QString csv_stringclean(const QString& string, const char* chararray);
 
 void
 xcsv_data_read(void);
index 28d75c99db9111e03b82ce115892da5aba783eb5..036316ed533c4fff4cd979d368ff53582b54877f 100644 (file)
@@ -174,12 +174,12 @@ enigma_waypt_disp(const waypoint* wpt)
     le_write32(&ewpt.data.wp_altitude, METERS_TO_FEET(wpt->altitude) + 1000);
   }
   if (wpt->shortname != NULL) {
-    ewpt.shortname_len = min(6, strlen(wpt->shortname));
-    strncpy(ewpt.shortname, wpt->shortname, 6);
+    ewpt.shortname_len = min(6, strlen(CSTRc(wpt->shortname)));
+    strncpy(ewpt.shortname, CSTRc(wpt->shortname), 6);
   }
   if (wpt->description != NULL) {
-    ewpt.longname_len = min(27, strlen(wpt->description));
-    strncpy(ewpt.longname, wpt->description, 27);
+    ewpt.longname_len = min(27, strlen(CSTRc(wpt->description)));
+    strncpy(ewpt.longname, CSTRc(wpt->description), 27);
   }
   gbfwrite(&ewpt, sizeof(ewpt), 1, file_out);
 }
index 2680eee9660eea4fc99286d2c56c117f16346cc7..449f8a097595e82b0eea4cab883a0078b8307d45 100644 (file)
@@ -144,7 +144,7 @@ fwrite_string(gbfile* fd, const char* str)
   }
 }
 static void
-fwrite_string(gbfile* fd, QString& str)
+fwrite_string(gbfile* fd, const QString& str)
 {
   if (str.isEmpty()) {
     fwrite_integer(fd, 0);
@@ -170,6 +170,12 @@ fwrite_fixedstring(gbfile* fd, const char* str, int fieldlen)
   }
 }
 
+void
+fwrite_fixedstring(gbfile* fd, const QString& str, int fieldlen)
+{
+  fwrite_fixedstring(fd, CSTR(str), fieldlen);
+}
+
 /* Auxiliar functions */
 
 #define MAX_INDATUM_INDEX 263
index 8d27c64067347886b0ea6e759b755ed634102a5b..5b7a2f245654c4fc3db7b4253772726d399163ee 100644 (file)
@@ -108,13 +108,11 @@ lowranceusr4_readstr(char* buf, const int maxlen, gbfile* file, int bytes_per_ch
 }
 
 static void
-lowranceusr4_writestr(char* buf, gbfile* file, unsigned int bytes_per_char)
+lowranceusr4_writestr(const QString& buf, gbfile* file, unsigned int bytes_per_char)
 {
   unsigned int len = 0;
 
-  if (buf) {
-    len = strlen(buf);
-  }
+  len = buf.length();
 
   if (0xffffffff / bytes_per_char < len) {
     /* be pedantic and check for the unlikely event that we are asked
@@ -125,10 +123,10 @@ lowranceusr4_writestr(char* buf, gbfile* file, unsigned int bytes_per_char)
   gbfputint32(len*bytes_per_char, file_out);
 
   if (bytes_per_char == 1) {
-    (void) gbfwrite(buf, 1, len, file);
+    (void) gbfwrite(CSTR(buf), 1, len, file);
   } else {
     for (unsigned int i = 0; i < len; ++i) {
-      gbfputc(buf[i], file_out);
+      gbfputc(buf[i].cell(), file_out);
       for (unsigned int j = 1; j < bytes_per_char; ++j) {
         gbfputc('\0', file_out);
       }
@@ -287,7 +285,11 @@ static char
 same_points(const waypoint* A, const waypoint* B)
 {
   return ( /* !!! We are case-sensitive !!! */
+#if NEW_STRINGS
+           (A->shortname == B->shortname) &&
+#else
            (strcmp(A->shortname, B->shortname) == 0) &&
+#endif
            (A->latitude == B->latitude) &&
            (A->longitude == B->longitude));
 }
index e910f029df319c3d5d1c622a50cf2cedad79e4d3..fbc47aa6aca3a6156e4e2359adf71d2fd27a4f16 100644 (file)
@@ -48,7 +48,7 @@ QString mag_find_descr_from_token(const char* token);
 QString mag_find_token_from_descr(const QString& icon);
 
 unsigned int mag_checksum(const char* const buf);
-char* m330_cleanse(char* istring);
+char* m330_cleanse(const char* istring);
 
 waypoint* mag_trkparse(char* trkmsg);
 void mag_rteparse(char* rtemsg);
index 28dc91f6e0603c4cc3239f22ac11d6d054021b17..540ff93995c256db697f19e029704523c77eb618 100644 (file)
@@ -130,16 +130,15 @@ ng_convert_datum(waypoint* wpt)
 /*=================== File read/write utilities ==========================================*/
 
 static void
-ng_fwrite_wp_data(char* s, char* d, ng_wp_data_t* wp_data, gbfile* f)
+ng_fwrite_wp_data(const QString& s, const QString& d, ng_wp_data_t* wp_data, gbfile* f)
 {
   int i;
   char z[50];
 
   memset(z, 0, 50);
-
-  i = (s == NULL) ? 0 : strlen(s);
+  i = s.length();
   gbfwrite(&i, 1, 1, f);
-  gbfwrite(s, 1, i, f);
+  gbfwrite(CSTR(s), 1, i, f);
 
   gbfwrite(&wp_data->pad1[0], 8, 1, f);
   gbfputint32(wp_data->East, f);
@@ -147,9 +146,9 @@ ng_fwrite_wp_data(char* s, char* d, ng_wp_data_t* wp_data, gbfile* f)
   gbfwrite(&wp_data->pad2[0], 2, 1, f);
   gbfputint32(wp_data->Alt, f);
 
-  i = (d == NULL) ? 0 : strlen(d);
+  i = d.length();
   gbfwrite(&i, 1, 1, f);
-  gbfwrite(d, 1, i, f);
+  gbfwrite(CSTR(d), 1, i, f);
   gbfwrite(z, 44, 1, f);
 }
 
@@ -238,8 +237,6 @@ ng_fill_waypoint_default(void)
 static void
 ng_waypt_rd(const waypoint* wpt)
 {
-  char* s = NULL;
-
   char z[50];
   double lat, lon;
   static int current_wp_ix=0;
@@ -255,6 +252,7 @@ ng_waypt_rd(const waypoint* wpt)
   WPNC.wp_data.North = (int32_t)lat;
   WPNC.wp_data.East = (int32_t)lon;
 
+  String s;
   if (reorder_wp) {
     sprintf(temp_short_name, "A%03d", current_wp_ix);
     s = temp_short_name;
index 404f91ac9010b580d6e41b9179764c649208054b..4d39f710a15706f9f4d8b834f66cd37e71064c12 100644 (file)
@@ -345,7 +345,7 @@ gpsutil_disp(const waypoint* wpt)
   gbfprintf(file_out, "W  %-6.6s %c%08.5f %c%011.5f %s %5.f %-40.40s %5e  %d\n",
             global_opts.synthesize_shortnames ?
             mkshort_from_wpt(mkshort_handle, wpt) :
-            wpt->shortname,
+            CSTRc(wpt->shortname),
             lat < 0.0 ? 'S' : 'N',
             fabs(lat),
             lon < 0.0 ? 'W' : 'E',